<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=8" />
	<title></title>
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
	<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
	<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
</head>
<body class="">
	<div id="inputArea">
		
	</div>
	
<script type="text/javascript">
	$(function(){
		$.get('http://wxapi.esheyi.com/weixinjs/getSignture', function(data) {
                
                var result = data.data;
                var timestamp = result.timestamp;
                var appId = result.appId;
                var nonceStr = result.nonceStr;
                var signature = result.signature;
                var url = result.url;
                var element = document.getElementById("inputArea");
	            element.innerHTML = timestamp + "|" + appId + "|" + nonceStr + "|" + url + "|" + signature;
                wx.config({
			        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
			        appId: appId, // 必填，公众号的唯一标识
			        timestamp: timestamp, // 必填，生成签名的时间戳
			        nonceStr: nonceStr, // 必填，生成签名的随机串
			        signature: signature,// 必填，签名，见附录1
			        jsApiList: ['scanQRCode'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
			    });
            });
	});

    //var timestamp = parseInt('${sign.timestamp}');//因为服务端是String类型，此处转化成数值类型
    //var nonceStr = '${sign.nonceStr}';
    //var signature = '${sign.signature}';
    //var appId = '${sign.appId}';
    
    wx.ready(function(){
        wx.scanQRCode({
                needResult: 1,// 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
                scanType:["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
                desc: 'scanQRCode desc',
                success: function (res) {
                    //扫码后获取结果参数:htpp://xxx.com/c/?6123，截取到url中的防伪码后，赋值给Input
                    window.location.href=res.resultStr;
                    // var element = document.getElementById("id_securityCode_input");
                    // element.innerHTML = res.resultStr;
                    // alert(res.resultStr);
                    // alert(res);
            }
        });
        
    });
    wx.error(function (res) {//错误时调用
        alert(res.errMsg);
    });
</script>
</body>
</html>

